<template>
  <div class="w1200 home_page">
    <!-- banner区域 开始 -->
    <div class="banner_box">
      <div class="menu_box">
        <li-link :to="item.url" class="a_link" v-for="(item, index) in menus" :key="`link_${index}`">
          <div class="left">
            <img :src="require('@/assets/images/home/' + item.icon)" class="img_normal" alt="" />
            <img :src="require('@/assets/images/home/' + item.active)" class="img_active" style="display:none;" alt="" />
            <span>{{ item.name }}</span>
          </div>
          <i class="el-icon-arrow-right"></i>
        </li-link>
      </div>

      <div class="banner">
        <HomeCarousel class="home_carousel" :list="bannerInfo" :show-dot="false" v-if="bannerInfo" />
        <img src="@/assets/images/home/banner@2x.png" class="img" alt="" v-else />
        <div class="banner_info">
          <div class="cell">
            <div class="num">
              <span>526000</span>
              <span class="plus">+</span>
            </div>
            <div class="tips">
              <img src="@/assets/images/home/icon_10.png" class="img" alt="" />
              <span class="name">累计服务人次</span>
            </div>
          </div>
          <div class="cell">
            <div class="num">
              <span>2100</span>
              <span class="plus">+</span>
            </div>
            <div class="tips">
              <img src="@/assets/images/home/icon_11.png" class="img" alt="" />
              <span class="name">累计入驻机构</span>
            </div>
          </div>
          <div class="cell">
            <div class="num">
              <span>5100</span>
              <span class="plus">+</span>
            </div>
            <div class="tips">
              <img src="@/assets/images/home/icon_12.png" class="img" alt="" />
              <span class="name">累计入驻医生</span>
            </div>
          </div>
        </div>
      </div>

      <div class="price_box">
        <h2 class="h2">查询您所在的城市看牙报价！</h2>
        <el-form ref="addForm" :model="addForm" :rules="addFormRules" :show-message="false" :inline-message="true">
          <el-form-item label="" prop="city">
            <el-cascader ref="carousel" v-model="addForm.city" class="a_select" popper-class="el_cascader"
              :options="cityJson" :props="props" placeholder="您所在的城市"></el-cascader>
          </el-form-item>
          <el-form-item label="" prop="troubleId">
            <el-select v-model="addForm.troubleId" class="a_select" placeholder="您的口腔问题">
              <el-option v-for="(item, index) in kqList" :key="index" :label="item.name" :value="item.id"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="" prop="phone">
            <el-input v-model="addForm.phone" class="a_input" maxlength="11" placeholder="输入手机号获取报价结果" />
          </el-form-item>
          <el-form-item>
            <el-checkbox v-model="checked" class="el_checkbox">
              <div class="deal_tips">
                我已阅读并且同意<li-link to="/contract">《哩哩口腔用户协议》</li-link>
              </div>
            </el-checkbox>
          </el-form-item>
          <el-form-item label="">
            <el-button type="primary" class="btn" :disabled="
              !checked ||
              !addForm.city ||
              !addForm.troubleId ||
              !addForm.phone
            " :loading="loading" @click="saveApplyInfo">获取报价</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
    <!-- banner区域 end -->

    <!-- 限时特惠 开始 -->
    <div class="row_box">
      <div class="row_head">
        <div class="left">
          <span class="name">限时特惠</span>
          <div class="labels">
            <template v-for="(item, index) in projectList">
              <nuxt-link :to="`/shop?projectId=${item.id}`" :key="`shop_project_${index}`" v-if="index < 5"
                class="label">{{ item.name }}</nuxt-link>
            </template>
            <!--             
            <div class="label">牙齿种植</div>
            <div class="label">牙齿矫正</div>
            <div class="label">牙齿贴面</div> -->
          </div>
        </div>
        <nuxt-link to="/shop" class="more">
          <span>更多</span>
          <i class="el-icon-arrow-right"></i>
        </nuxt-link>
      </div>
      <div class="row_content">
        <div class="goods_list">
          <Goods v-for="(item, index) in goodsList" :key="index" :info="item"></Goods>
        </div>
      </div>
    </div>
    <!-- 限时特惠 end -->

    <div class="qualification">
      <!-- 推荐医院 开始 -->
      <div class="row_box">
        <div class="row_head">
          <div class="left">
            <span class="name">推荐医院</span>
            <div class="labels">
              <template v-for="(item, index) in hospTypeList">
                <nuxt-link :to="`/hospital?classId=${item.id}`" :key="`hosp_type_${index}`" class="label"
                  v-if="index < 5">{{ item.name }}</nuxt-link>
              </template>
            </div>
          </div>
          <nuxt-link to="/hospital" class="more">
            <span>更多</span>
            <i class="el-icon-arrow-right"></i>
          </nuxt-link>
        </div>
        <div class="row_content">
          <div class="hospital_list" v-if="hospitalList && hospitalList.length">
            <template v-for="(item, index) in 3">
              <Hospital :key="`hospital_${index}`" v-if="hospitalList[index] && hospitalList[index].id"
                :info="hospitalList[index] || {}" :logo="$getLogo(hospitalList[index].surroundingsPics)" />
              <!-- :logo="$getLogo(hospitalList[index].)" -->
            </template>
          </div>
          <div class="hospital_list hospital_sort_list" v-if="hospitalList && hospitalList.length > 3">
            <nuxt-link :to="`/hospital/${item.id}`" class="link" v-for="(item, index) in getHospitalList(hospitalList)"
              :key="`hospital_link_${index}`">{{ item.name }}</nuxt-link>

          </div>
        </div>
      </div>
      <!-- 推荐医院 end -->

      <!-- 查资质 开始 -->
      <div class="certification">
        <div class="banner">
          <img src="@/assets/images/home/cer_banner.png" alt="" />
        </div>
        <h2 class="title">查询资质</h2>
        <div class="tabs_menu">
          <div class="cell" :class="activeName == item.id ? 'cell_active' : ''" v-for="(item, index) in tabsList"
            :key="`tabs_${index}`" @click="tabEvent(item)">
            {{ item.name }}
          </div>
        </div>
        <div class="search">
          <el-input v-model="term" class="a_input" />
          <el-button type="primary" class="btn" @click="goSearch">立即搜索</el-button>
        </div>
        <div class="hot_word">
          <h2 class="word">热门搜索词</h2>
          <div class="list">
            <a href="javascript:void(0)" v-for="(item, index) in hotList" :key="`word_${index}`"
              @click="chooseWord(item)">{{ item.name }}</a>
          </div>
        </div>
        <div class="desc">
          <p>说明：</p>
          <p>
            1、未查询到相关信息不代表其资质有问题，有可能是因为系统暂未收录；
          </p>
          <p>
            2、信息均来自网友上传或网络转载，其原创性和内容未经本站证实，仅供参考
          </p>
        </div>
      </div>
      <!-- 查资质 end -->
    </div>

    <!-- 推荐医生 开始 -->
    <div class="row_box">
      <div class="row_head">
        <div class="left">
          <span class="name">推荐医生</span>
          <div class="labels">
            <template v-for="(item, index) in projectList">
              <nuxt-link :to="`/doctor?projectId=${item.id}`" :key="`doctor_project_${index}`" v-if="index < 5"
                class="label">{{ item.name }}</nuxt-link>
            </template>
          </div>
        </div>
        <nuxt-link to="/doctor" class="more">
          <span>更多</span>
          <i class="el-icon-arrow-right"></i>
        </nuxt-link>
      </div>
      <div class="row_content">
        <div class="doctor_list">
          <Doctor v-for="(item, index) in doctorList" :key="`doctor_${index}`" :info="item" />
        </div>
      </div>
    </div>
    <!-- 推荐医生 end -->

    <!-- 社区问答 开始 -->
    <div class="row_box">
      <div class="row_head">
        <div class="left">
          <span class="name">社区问答</span>
        </div>
        <nuxt-link to="/question" class="more">
          <span>更多</span>
          <i class="el-icon-arrow-right"></i>
        </nuxt-link>
      </div>
      <div class="row_content">
        <div class="news_box">
          <div class="title_list">
            <!-- 单条数据 开始 -->
            <div class="cell" :class="newsActive == item.id ? 'cell_active' : ''" v-for="(item, index) in questionList"
              :key="`news_${index}`" @click="chooseQuestion(item)">
              <span class="num">0{{ index + 1 }}</span>
              <div class="info">
                <div class="title" :title="item.question">
                  {{ item.question }}
                </div>
                <div class="time">
                  <span>{{ item.initReadCnt }} 浏览·{{
                    $getAnswerList(item)
                  }}回答</span>
                  <span class="circle"><i class="el-icon-arrow-right"></i></span>
                </div>
              </div>
            </div>
            <!-- 单条数据 end -->
          </div>
          <div class="news_content">
            <h3 class="h3">
              <nuxt-link :to="`/question/${currentQuestion.id}`">{{
                currentQuestion.question
              }}</nuxt-link>
            </h3>
            <div class="square">
              <span></span>
              <span></span>
              <span></span>
            </div>
            <div class="question">
              <p>{{ currentQuestion.introduce }}</p>
            </div>
            <div class="btn_box">
              <el-button type="primary" class="btn" @click="lookDetail(currentQuestion)">查看详情</el-button>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- 社区问答 end -->

    <!-- 口腔资讯 开始 -->
    <div class="row_box kq_news">
      <div class="row_head">
        <div class="left">
          <span class="name">口腔资讯</span>
          <div class="labels">
            <nuxt-link :to="`/news?articleClassId=${item.id}`" class="label" v-for="(item, index) in classList"
              :key="`news_class_${index}`">{{ item.name }}</nuxt-link>
            <!-- <div class="label">新闻资讯</div>
                        <div class="label">行业动态</div>
                        <div class="label">前沿技术</div>
                        <div class="label">口腔健康</div> -->
          </div>
        </div>
        <nuxt-link to="/news" class="more">
          <span>更多</span>
          <i class="el-icon-arrow-right"></i>
        </nuxt-link>
      </div>
      <div class="row_content information_box">
        <!-- 轮播图 开始 -->
        <SimpleCarousel :list="prevThreeNews" class="news_carousel" />
        <!-- 轮播图 end -->

        <!-- 前两条资讯 开始 -->
        <div class="prev_news">
          <div class="news_cell" v-for="(item, index) in midTwoNews" :key="`prev_news_${index}`" @click="lookNews(item)">
            <div class="title">{{ item.articleName }}</div>
            <div class="desc">{{ item.introduce }}</div>
            <el-divider class="el_divider"></el-divider>
            <div class="date_box">
              <div class="time">
                <span class="day">{{ formatDay(item.createdDate) }}</span>
                <span>{{ formatYearMonth(item.createdDate) }}</span>
              </div>
              <div class="arrow"></div>
            </div>
          </div>
        </div>
        <!-- 前两条资讯 end -->

        <!-- 后面资讯 开始 -->
        <div class="next_news">
          <div class="news_cell" v-for="(item, index) in lastThreeNews" :key="`next_news_${index}`"
            @click="lookNews(item)">
            <div class="date_box">
              <span class="day">{{ formatDay(item.createdDate) }}</span>
              <span>{{ formatYearMonth(item.createdDate) }}</span>
            </div>
            <el-divider direction="vertical" class="el_divider"></el-divider>
            <div class="info">
              <div class="title">{{ item.articleName }}</div>
              <div class="arrow"></div>
            </div>
          </div>
        </div>
        <!-- 后面资讯 end -->
      </div>
    </div>
    <!-- 口腔资讯 end -->

    <!-- 口腔健康 开始 -->
    <div class="science">
      <div class="info">
        <div class="cell_box">
          <nuxt-link to="/baike/1" class="cell">
            <span class="name">什么是种植牙？</span>
            <span class="sub">优缺点、适应症、禁忌症</span>
          </nuxt-link>
          <div class="cell_two">
            <nuxt-link to="/baike/1" class="cell">
              <span class="name">种植牙治疗流程</span>
              <span class="sub">3-6月完成</span>
            </nuxt-link>
            <nuxt-link to="/baike/1" class="cell cell_orange">
              <span class="name">种植牙术后护理</span>
              <span class="sub">术后注意项目</span>
            </nuxt-link>
          </div>
          <nuxt-link to="/baike/1" class="cell cell_04 mt0">
            <span class="name">种植牙品牌大全</span>
            <span class="sub">诺贝尔、iti、奥齿泰...</span>
          </nuxt-link>
        </div>

        <div class="cell_box">
          <nuxt-link to="/baike/2" class="cell cell_05">
            <span class="name">什么是牙齿矫正？</span>
            <span class="sub">优缺点、适应症、禁忌症</span>
          </nuxt-link>
          <div class="cell_two">
            <nuxt-link to="/baike/2" class="cell">
              <span class="name">牙齿矫正流程</span>
              <span class="sub">1-2年完成</span>
            </nuxt-link>
            <nuxt-link to="/baike/2" class="cell cell_orange">
              <span class="name">矫正过程护理</span>
              <span class="sub">注意项目</span>
            </nuxt-link>
          </div>
          <nuxt-link to="/baike/2" class="cell cell_04 mt0">
            <span class="name">牙齿矫正品牌大全</span>
            <span class="sub">时代天使、隐适美...</span>
          </nuxt-link>
        </div>

        <div class="cell_box">
          <div class="cell_two">
            <nuxt-link to="/baike/5" class="cell cell_06">
              <span class="name">牙齿贴面</span>
              <span class="sub">美白神器</span>
            </nuxt-link>
            <nuxt-link to="/baike/10" class="cell cell_07">
              <span class="name">龋齿</span>
              <span class="sub">虫牙、蛀牙</span>
            </nuxt-link>
          </div>
          <nuxt-link to="/baike/4" class="cell cell_08">
            <span class="name">根管治疗</span>
            <span class="sub">优缺点、适应症、禁忌症</span>
          </nuxt-link>
          <nuxt-link to="/baike/6" class="cell cell_09 mt0">
            <span class="name">牙周治疗</span>
            <span class="sub">牙龈炎、牙周炎...</span>
          </nuxt-link>
        </div>
      </div>
    </div>
    <!-- 口腔健康 end -->

    <!-- 特点介绍 开始 -->
    <div class="special_box">
      <div class="cell">
        <img src="@/assets/images/home/special_01.png" alt="价格实惠" />
        <span class="name">价格实惠</span>
        <span>低至市场50%</span>
      </div>

      <div class="cell">
        <img src="@/assets/images/home/special_02.png" alt="费用透明" />
        <span class="name">费用透明</span>
        <span>费用清晰，无隐形消费</span>
      </div>

      <div class="cell">
        <img src="@/assets/images/home/special_03.png" alt="贴心服务" />
        <span class="name">贴心服务</span>
        <span>24小时1对1专属服务</span>
      </div>

      <div class="cell">
        <img src="@/assets/images/home/special_04.png" alt="售后保障" />
        <span class="name">售后保障</span>
        <span>全程跟进，平台保障</span>
      </div>
    </div>
    <!-- 特点介绍 end -->

    <!-- 在线客服 开始 -->
    <OnlineService />
    <!-- 在线客服 end -->
  </div>
</template>
<script>
import {
  Input,
  Form,
  FormItem,
  Checkbox,
  Carousel,
  CarouselItem,
  Divider,
  Cascader,
  Select,
  Option,
} from "element-ui";
import Hospital from "@/components/hospital/index.vue";
import Goods from "@/components/goods/index.vue";
import Doctor from "@/components/doctor/index.vue";
import OnlineService from "@/components/service/index.vue";
import SimpleCarousel from "@/components/carousel/carousel.vue";
import HomeCarousel from "@/components/carousel/HomeCarousel.vue";
import {
  PLATFORM_TYPE,
  GET_HOSPITAL_SEARCH,
  GET_DOCTOR_SEARCH,
  GET_GOODS_SEARCH,
  GET_QUESTIONANSWER_SEARCH,
  GET_SEO_SETTING_INFO,
  GET_ADVERTISEMENT_INFO,
  GET_ARTICLE_CLASS_OPTIONS,
  GET_ARTICLE_SEARCH,
  GET_ORALCAVITY_TROUBLE_OPTIONS,
  GET_QUOTATION_QUERY,
  GET_KEYWORDS_OPTIONS,
  GET_HOSPITAL_CLASS_OPTIONS,
  GET_HOSPITAL_PROJECT_OPTIONS,
} from "@/http/interface";
import { sliceNews, deepClone, showToast, showModal } from "@/utils/utils";
import cityJson from "@/assets/json/city.json";
import { PHONE_VALIDATOR } from "@/utils/validator";
export default {
  components: {
    [Input.name]: Input,
    [Form.name]: Form,
    [FormItem.name]: FormItem,
    [Checkbox.name]: Checkbox,
    [Carousel.name]: Carousel,
    [CarouselItem.name]: CarouselItem,
    [Divider.name]: Divider,
    [Cascader.name]: Cascader,
    [Select.name]: Select,
    [Option.name]: Option,
    Hospital,
    Goods,
    Doctor,
    OnlineService,
    SimpleCarousel,
    HomeCarousel,
  },
  data() {
    return {
      menus: [
        { name: "牙齿种植", url: "/baike/1", icon: "icon_01.png",active:"icon_01_active.png", id: 1 },
        { name: "牙齿矫正", url: "/baike/2", icon: "icon_02.png",active:"icon_02_active.png", id: 2 },
        { name: "牙齿贴面", url: "/baike/5", icon: "icon_03.png",active:"icon_03_active.png", id: 3 },
        { name: "牙齿美白", url: "/baike/8", icon: "icon_04.png",active:"icon_04_active.png", id: 4 },
        { name: "根管治疗", url: "/baike/4", icon: "icon_05.png",active:"icon_05_active.png", id: 5 },
        { name: "牙周治疗", url: "/baike/6", icon: "icon_06.png",active:"icon_06_active.png", id: 6 },
        { name: "牙齿修复", url: "/baike/9", icon: "icon_07.png",active:"icon_07_active.png", id: 7 },
        { name: "智齿拔除", url: "/baike/7", icon: "icon_08.png",active:"icon_08_active.png", id: 8 },
        { name: "龋齿/蛀牙", url: "/baike/10", icon: "icon_09.png",active:"icon_09_active.png", id: 9 },
      ],
      addForm: {},
      checked: true,
      activeName: 1,
      tabsList: [
        { name: "查医院", id: 1 },
        { name: "查医生", id: 2 },
        { name: "查材料", id: 3 },
      ],
      term: "",
      newsActive: "",
      carouselIndex: 0,
      seoInfo: {},
      bannerInfo: [],
      hospitalList: [],
      doctorList: [],
      goodsList: [],
      questionList: [],
      currentQuestion: {},
      classList: [],
      newsList: [],
      prevThreeNews: [],
      midTwoNews: [],
      lastThreeNews: [],
      kqList: [],
      cityJson,
      props: {
        value: "code",
        label: "name",
      },
      addFormRules: {
        city: [
          { required: true, message: "请选择您所在的城市", trigger: "change" },
        ],
        troubleId: [
          { required: true, message: "请选择您的口腔问题", trigger: "change" },
        ],
        phone: [
          { required: true, message: "请输入手机号", trigger: "nlur" },
          { validator: PHONE_VALIDATOR, trigger: "blur" },
        ],
      },
      loading: false,
      hotList: [],
      hospTypeList: [],
      projectList: [],
    };
  },
  head() {
    return {
      title: this.seoInfo.title,
      meta: [
        {
          hid: "description",
          name: "description",
          content: this.seoInfo.description,
        },
        {
          hid: "Keywords",
          name: "Keywords",
          content: this.seoInfo.keywords,
        },
      ],
      link:[
        {ref:'canonical',href:`${this.$domain}/home`}
      ]
    };
  },
  async asyncData({ query, $axios, $cookies }) {
    let city = $cookies.get("city");
    let params = { pageNumber: 1, pageSize: 4, homePageShow: 1 };

    // 获取seo配置
    let seo = await $axios.get(GET_SEO_SETTING_INFO, {
      params: { type: 0, platform: PLATFORM_TYPE },
    });
    let seoInfo = seo.data || {};
    console.log(seoInfo);

    // 获取banner图
    let bes = await $axios.get(GET_ADVERTISEMENT_INFO, {
      params: { position: 1 },
    });
    let bannerInfo = bes.data || [];
    console.log("banner", bannerInfo);

    // 获取医院列表
    let oParams = { pageNumber: 1, pageSize: 15, homePageShow: 1 };
    // if (city && city != "全国") {
    //   oParams.city = city;
    // }
    let res = await $axios.get(GET_HOSPITAL_SEARCH, { params: oParams });
    let obj = res.data || {};
    let hospitalList = obj.list || [];

    // 获取医生
    let dParams = { ...params };
    // if (city && city != "全国") {
    //   dParams.city = city;
    // }
    let des = await $axios.get(GET_DOCTOR_SEARCH, { params: dParams });
    let dobj = des.data || {};
    let doctorList = dobj.list || [];

    // 获取商品
    let gParams = { ...params };
    // if (city && city != "全国") {
    //   gParams.city = city;
    // }
    gParams.pageSize = 5;
    let ges = await $axios.get(GET_GOODS_SEARCH, { params: gParams });
    let gobj = ges.data || {};
    let goodsList = gobj.list || [];

    // 获取社区问答
    let aes = await $axios.get(GET_QUESTIONANSWER_SEARCH, {
      params: { pageNumber: 1, pageSize: 5, homePageShow: 1 },
    });
    let aobj = aes.data || {};
    let questionList = aobj.list || [];
    let currentQuestion = questionList[0] || {};

    // 获取文章分类
    let tes = await $axios.get(GET_ARTICLE_CLASS_OPTIONS);
    let classList = tes.data || [];

    // 获取新闻资讯
    let news = await $axios.get(GET_ARTICLE_SEARCH, {
      params: { pageNumber: 1, pageSize: 8, homePageShow: 1 },
    });
    let nobj = news.data || {};
    let newsList = nobj.list || [];
    let _news = sliceNews(newsList);

    let kqes = await $axios.get(GET_ORALCAVITY_TROUBLE_OPTIONS);
    let kqList = kqes.data || [];

    // 医院类型
    let typeres = await $axios.get(GET_HOSPITAL_CLASS_OPTIONS);
    let hospTypeList = typeres.data || [];

    // 擅长项目
    let pro = await $axios.get(GET_HOSPITAL_PROJECT_OPTIONS);
    let projectList = pro.data || [];

    return {
      seoInfo,
      bannerInfo,
      hospitalList,
      doctorList,
      goodsList,
      questionList,
      currentQuestion,
      newsActive: currentQuestion.id || "",
      classList,
      newsList,
      prevThreeNews: _news[0] || [],
      midTwoNews: _news[1] || [],
      lastThreeNews: _news[2] || [],
      kqList,
      hospTypeList,
      projectList,
    };
  },
  mounted() {
    this.getHotWord();
  },
  methods: {
    // 监听轮播图切换
    changeCarousel(e) {
      this.carouselIndex = e;
    },

    // 手动切换轮播图
    chooseCarousel(e) {
      this.carouselIndex = e;
      this.$refs.carousel.setActiveItem(e);
    },

    // 获取医院列表
    getHospitalList(list) {
      let arr = list.slice(3, list.length);
      return arr;
    },

    // 新闻点击事件
    chooseQuestion(row) {
      this.currentQuestion = row;
      this.newsActive = row.id;
    },

    // 查看新闻
    lookNews(row) {
      this.$router.push({
        path: "/news/detail",
        query: {
          id: row.id,
        },
      });
    },

    // 格式化天
    formatDay(str) {
      if (!str) {
        return "";
      }
      let m = new Date(str);
      let n = m.getDay();
      let day = n < 10 ? "0" + n : n;
      return day;
    },

    // 格式化年月
    formatYearMonth(str) {
      if (!str) {
        return "";
      }
      let m = new Date(str);
      let y = m.getFullYear();
      let n = m.getMonth() + 1;
      let month = n < 10 ? "0" + n : n;
      let _day = `${y}.${month}`;
      return _day;
    },

    // 保存信息
    saveApplyInfo() {
      let _this = this;
      _this.$refs.addForm.validate((valid) => {
        if (!valid) {
          return false;
        }
        _this.sendInfo();
      });
    },

    // 发送请求
    async sendInfo() {
      let _this = this;
      let nodes = _this.$refs.carousel.getCheckedNodes(true)[0];
      let o = deepClone(_this.addForm);
      let params = { ...o };
      params.city = nodes.data.code;
      params.cityName = nodes.data.name;
      params.platform = PLATFORM_TYPE;
      _this.loading = true;
      let res = await _this.$axios.post(GET_QUOTATION_QUERY, params);
      _this.loading = false;
      if (res.code == 200) {
        showModal({
          title: "提示信息",
          message: "您已提交成功，稍后将安排专人给您报价，请注意接听！",
          showCancelButton: true,
          type: "success",
        });
        _this.addForm = {};
        setTimeout(function () {
          _this.$refs.addForm.clearValidate();
        }, 30);
      }
    },

    // 查看详情
    lookDetail(row) {
      let query = this.$route.query;
      this.$router.push({
        path: `/question/${row.id}`,
        //query: { ...query, id: row.id },
      });
    },

    // 查询资质 切换
    tabEvent(row) {
      this.activeName = row.id;
      this.getHotWord();
    },

    // 获取热门关键词
    async getHotWord() {
      let params = {};
      params.type = this.activeName || 1;
      // 获取热门关键词
      let hot = await this.$axios.get(GET_KEYWORDS_OPTIONS, { params: params });
      let hotList = hot.data || [];
      if (hotList.length > 5) {
        hotList.length = 5;
      }
      this.hotList = hotList;
    },

    // 选择关键词
    chooseWord(row) {
      this.term = row.name;
    },

    // 去搜索
    goSearch() {
      let query = {};
      query.term = this.term;
      query.type = this.activeName;
      this.$routerPush("/certification", query);
    },
  },
};
</script>
<style lang="less" scoped>
@import "/assets/styles/index/home.less";
</style>